package com.itheima.service.impl;

import com.itheima.mapper.StatisticsMapper;
import com.itheima.pojo.EmpStatistics;
import com.itheima.pojo.StuStatistics;
import com.itheima.service.StatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StatisticsServiceImpl implements StatisticsService {
    private static final Logger log = LoggerFactory.getLogger(StatisticsServiceImpl.class);
    @Autowired
    private StatisticsMapper statisticsMapper;

    @Override
    public List<Map> queryGenderList() {
        List<Map> list = statisticsMapper.getGenderList();
        return list;
    }

    @Override
    public EmpStatistics queryJobList() {
        List<Map> list = statisticsMapper.getJobList();
        List<Object> jobList = list.stream().map(s->s.get("jobList")).toList();
        List<Object> dataList = list.stream().map(s->s.get("dataList")).toList();
        return new EmpStatistics(jobList,dataList);
    }

    @Override
    public List<Map> queryStudentDegreeData() {
        List<Map> list = statisticsMapper.getStudentDegreeData();
        return list;
    }

    @Override
    public StuStatistics queryStudentCountData() {
        List<Map> list = statisticsMapper.getstudentCountData();
        List<Object> jobList = list.stream().map(s->s.get("clazzList")).toList();
        List<Object> dataList = list.stream().map(s->s.get("dataList")).toList();
        return new StuStatistics(jobList,dataList);
    }
}
